package fatboy.hypeerweb;

import junit.framework.Assert;


/**
 * The Last-Node State.  
 * A "last" node must have no children and must have an empty list of
 *  up/down pointers.  It is the node with the greatest address in the hyper cube. 
 * It's fold (complement) is the zero-node.  There will only be one node in the 
 * "last" state at any time.  When a node is in the "last" state, 
 * no nodes will be in the "edge" state.  
 * (A "last" node will have a height that is equal to the height of the "complete"
 *  hypercube.)
 *  
 * @author Preston Cowley
 * @domain a singleton instance
 */

class LastNodeState extends NodeState {

	@Override
	public Node findInsertionPoint(Node thisNode) {
		return thisNode.getFold();
	}

	@Override
	protected Node getSurfaceOrLastNode(Node thisNode) {
		return thisNode;
	}

	@Override
	public boolean hasEdgeChild(Node thisNode) {
		return false; //this method is never supposed to be called on the LastNode
	}

	@Override
	public boolean hasParent(Node thisNode) {
		return false; //this method is never supposed to be called on the LastNode
	}

	@Override
	public NodeAddress getFirstUpDownNodeAddress(Node thisNode) {
		return null;
	}
	
	protected NodeType getType() {
		return NodeType.LAST_NODE;
	}

	@Override
	public void assertNodeStateIsCorrect(Node thisNode) {
		Assert.assertTrue(thisNode.getPointers().isEmpty());
		Assert.assertEquals(thisNode.getChild().getNodeType(),NodeType.NULL_NODE);
	}


}
